package com.pehulja.mmdo.coursework.math;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * It is just dummy container of sets. Used to store sets
 * of used combinations of wrong combinations of components
 * during searching first basic plan of task
 * @param <T>
 */
public class ContainerOfSet <T>{
    private Set container;

    public Set getContainer() {
        return container;
    }

    public void setContainer(Set container) {
        this.container = container;
    }

    public ContainerOfSet(Set container) {
        this.container = container;
    }

    public ContainerOfSet() {
        container = new HashSet();
    }

    public ContainerOfSet(T[] element) {
        container = new HashSet();
        this.addAll(element);
    }

    public ContainerOfSet(Collection element) {
        container = new HashSet();
        this.add(element);
    }

    public <T> boolean add(T element){
        return container.add(element);
    }

    public <T> boolean addAll(T[] element){
        return container.addAll(Arrays.asList(element));
    }

    public boolean add(Collection element){
        return container.addAll(element);
    }

    @Override
    public boolean equals(Object o) {
        System.out.println("equals");
        if (this == o) return true;
        if (!(o instanceof ContainerOfSet)) return false;

        ContainerOfSet set = (ContainerOfSet) o;

        if (!container.equals(set.container)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return container.hashCode();
    }
}
